int myAtoi(char* str) {

    if ((*str > '9' || *str < '0') && (*str != '+' && *str != '-') && (*str != ' '))
    {
        return 0;
    }

    while (*str == ' ')
        str++;
    bool judge1 = false;
    bool judge2 = false;
    int i = 0;
    if (*str == '-')
    {
        judge1 = true;
        i = -1;
        str++;
    }

    if (*str == '+')
    {
        str++;
        judge2 = true;
    }

    if (judge1 == true && judge2 == true)
        return 0;

    long  sum = 0;
    while (*str >= '0' && *str <= '9')
    {
        sum = sum * 10 + (*str - '0');

        if (sum > INT_MAX && judge1 == false)
            return INT_MAX;
        else if (-sum < INT_MIN && judge1 == true)
            return INT_MIN;

        str++;
    }

    if (judge1)
        sum *= i;
    return (int)(sum);

}
